

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="zh-CN" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="zh-CN" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>WeIdentity JAVA SDK 安装部署工具（不部署智能合约） &mdash; WeIdentity  文档</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/theme_overrides.css" type="text/css" />
  <link rel="stylesheet" href="../_static/index.css" type="text/css" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" /> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> WeIdentity
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../README.html">什么是 WeIdentity？</a></li>
<li class="toctree-l1"><a class="reference internal" href="one-stop-experience.html">WeIdentity 一站式体验</a></li>
<li class="toctree-l1"><a class="reference internal" href="terminologies.html">术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="use-cases.html">使用场景</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-spec.html">WeIdentity 规范</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-installation.html">WeIdentity Java SDK 安装部署</a></li>
<li class="toctree-l1"><a class="reference external" href="https://weidentity.readthedocs.io/projects/javasdk/zh_CN/latest/">WeIdentity Java SDK 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-sample.html">WeIdentity Sample 开发样例</a></li>
<li class="toctree-l1"><a class="reference internal" href="miscellaneous.html">杂项</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-rest.html">WeIdentity RestService</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-endpoint.html">WeIdentity Endpoint Service</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-contract-design.html">WeIdentity 智能合约设计与实现</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">WeIdentity</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
      <li>WeIdentity JAVA SDK 安装部署工具（不部署智能合约）</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/docs/weidentity-build-without-deploy.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="weidentity-java-sdk">
<span id="weidentity-build-without-deploy"></span><h1>WeIdentity JAVA SDK 安装部署工具（不部署智能合约）<a class="headerlink" href="#weidentity-java-sdk" title="永久链接至标题">¶</a></h1>
<div class="section" id="id1">
<h2>整体介绍<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
<p>一条区块链里，有多家机构，只需要一家机构部署 WeIdentity 智能合约，部署完成后，将智能合约地址给到其他机构即可。</p>
<ul class="simple">
<li><p>不部署 WeIdentity 智能合约的机构，参考本文档完成安装部署和集成。</p></li>
<li><p>部署 WeIdentity 智能合约的机构，可以参考<a class="reference external" href="./weidentity-build-with-deploy.html">WeIdentity Java SDK 安装部署工具（部署智能合约</a>。</p></li>
</ul>
</div>
<div class="section" id="id2">
<h2>部署步骤<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
<div class="section" id="weidentity">
<h3>1. 部署 WeIdentity 智能合约<a class="headerlink" href="#weidentity" title="永久链接至标题">¶</a></h3>
<div class="section" id="id3">
<h4>1.1 下载安装部署工具<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">WeBankBlockchain</span><span class="o">/</span><span class="n">weid</span><span class="o">-</span><span class="n">build</span><span class="o">-</span><span class="n">tools</span><span class="o">.</span><span class="n">git</span>
</pre></div>
</div>
</div>
<div class="section" id="id4">
<h4>1.2  配置基本信息<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h4>
<p>weid-java-sdk 可以同时支持 FISCO BCOS 1.3版本和 FISCO BCOS 2.0 版本。</p>
<div class="section" id="id5">
<h5>1.2.1  基本配置<a class="headerlink" href="#id5" title="永久链接至标题">¶</a></h5>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">weid</span><span class="o">-</span><span class="n">build</span><span class="o">-</span><span class="n">tools</span>
<span class="n">vim</span> <span class="n">run</span><span class="o">.</span><span class="n">config</span>
</pre></div>
</div>
<ul class="simple">
<li><p>配置区块链节点信息，填入区块链节点 IP 和 Channel端口，示例如下：</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>区块链节点Channel端口说明见<a class="reference external" href="https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/manual/configuration.html#rpc">FISCO BCOS 2.0配置文件说明</a>或 <a class="reference external" href="https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-1.3/docs/web3sdk/config_web3sdk.html#java">FISCO BCOS 1.3 配置文件说明</a>。</p>
</div>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">blockchain_address</span><span class="o">=</span><span class="m">10</span>.10.10.10:20200
</pre></div>
</div>
<ul class="simple">
<li><p>如果需要配置多个区块链节点，用逗号分隔，示例如下：</p></li>
</ul>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">blockchain_address</span><span class="o">=</span><span class="m">10</span>.10.10.10:20200,10.10.10.11:20200
</pre></div>
</div>
<ul class="simple">
<li><p>配置 FISCO BCOS 版本信息，如果您使用 FISCO BCOS 2.0 版本则配置为2，FISCO BCOS 1.3 则配置为 1：</p></li>
</ul>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">blockchain_fiscobcos_version</span><span class="o">=</span><span class="m">2</span>
</pre></div>
</div>
<ul class="simple">
<li><p>配置机构名称，该名称也被用作后续机构间的 <a class="reference external" href="https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/manual/amop_protocol.html">AMOP</a> 通信标识。</p></li>
</ul>
<p>假设您的机构名为 test，您可以配置为：</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">org_id</span><span class="o">=</span><span class="nb">test</span>
</pre></div>
</div>
<ul class="simple">
<li><p>配置 chain-id，该配置项用于路由到不同的网络，假设您的 chain-id 定义为1，则您可以配置为：</p></li>
</ul>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nv">chain_id</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<p>保存退出，即完成基本配置。</p>
</div>
<div class="section" id="id6">
<h5>1.2.2 配置节点证书和秘钥文件<a class="headerlink" href="#id6" title="永久链接至标题">¶</a></h5>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">resources</span><span class="o">/</span>
</pre></div>
</div>
<p>FISCO BCOS 2.0请参考<a class="reference external" href="https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/java_sdk.html">2.0 web3sdk客户端配置</a>将证书文件 <code class="docutils literal notranslate"><span class="pre">ca.crt</span></code>， <code class="docutils literal notranslate"><span class="pre">node.crt</span></code> 和 <code class="docutils literal notranslate"><span class="pre">node.key</span></code> 复制出来，拷贝至当前目录下。</p>
<p>FISCO BCOS 1.3请参考<a class="reference external" href="https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-1.3/docs/tools/web3sdk.html">1.3 web3sdk客户端配置</a>将证书文件 <code class="docutils literal notranslate"><span class="pre">ca.crt</span></code> 和 <code class="docutils literal notranslate"><span class="pre">client.keystore</span></code> 复制出来，拷贝至当前目录下 。</p>
</div>
</div>
<div class="section" id="id7">
<h4>1.3 部署智能合约并自动生成配置文件<a class="headerlink" href="#id7" title="永久链接至标题">¶</a></h4>
</div><ul class="simple">
<li><p>如果您是第一次使用本工具，您需要先进行编译：</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">注解</p>
<div class="line-block">
<div class="line">如果您重新修改了 <code class="docutils literal notranslate"><span class="pre">run.config</span></code> 里的配置项，您也需要重新编译。</div>
</div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="o">..</span>
<span class="n">chmod</span> <span class="o">+</span><span class="n">x</span> <span class="nb">compile</span><span class="o">.</span><span class="n">sh</span>
<span class="o">./</span><span class="nb">compile</span><span class="o">.</span><span class="n">sh</span>
</pre></div>
</div>
<p>如果执行过程没报错，大约半分钟左右可以编译完成。</p>
<p>1.4 配置您的配置文件</p>
<p>您需要向发布 WeIdentity 智能合约的机构索要智能合约地址，并将对应的智能合约地址填入对应的项。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">resources</span><span class="o">/</span>
<span class="n">vim</span> <span class="n">fisco</span><span class="o">.</span><span class="n">properties</span>
</pre></div>
</div>
<p>您需要将每个配置项替换成对应的智能合约地址，比如，如果 WeID Contract 的发布地址是0xabbc75543648af0861b14daa4f8582f28cd95f5e，
您需要将 <code class="docutils literal notranslate"><span class="pre">weId.contractaddress</span></code> 对应的值替换成 0xabbc75543648af0861b14daa4f8582f28cd95f5e，变成以下内容：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">weid</span><span class="o">.</span><span class="n">contractaddress</span><span class="o">=</span><span class="mh">0xabbc75543648af0861b14daa4f8582f28cd95f5e</span>
</pre></div>
</div>
<p>其他的 <code class="docutils literal notranslate"><span class="pre">cpt.contractaddress</span></code>， <code class="docutils literal notranslate"><span class="pre">issuer.contractaddress</span></code>， <code class="docutils literal notranslate"><span class="pre">evidence.contractaddress</span></code> 和 <code class="docutils literal notranslate"><span class="pre">specificissuer.contractaddress</span></code> 都进行对应的智能合约地址替换，完成后保存退出即可。</p>
<p>至此，您已经完成 weid-java-sdk 的安装部署，您可以开始您的 Java 应用集成以及便捷工具体验。</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>一条联盟链里，当一家机构部署 WeIdentity 智能合约成功后，需要将上述智能合约地址发给其他机构。</p>
</div>
</div>
</div>
<div class="section" id="weid-java-sdk">
<h3>2 weid-java-sdk 的集成<a class="headerlink" href="#weid-java-sdk" title="永久链接至标题">¶</a></h3>
<div class="section" id="java-weid-java-sdk">
<h4>2.1 在自己的Java应用中引入 weid-java-sdk<a class="headerlink" href="#java-weid-java-sdk" title="永久链接至标题">¶</a></h4>
<p>在自己的 Java 应用通过 <code class="docutils literal notranslate"><span class="pre">build.gradle</span></code> 引入，目前 weid-java-sdk 暂时只支持 gradle 方式引入。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">compile</span><span class="p">(</span><span class="s2">&quot;com.webank:weid-java-sdk:1.3.2&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="java">
<h4>2.2 配置您的Java应用<a class="headerlink" href="#java" title="永久链接至标题">¶</a></h4>
<p>将 weid-build-tools 里配置好的配置文件拷贝至您的Java应用中：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">resources</span><span class="o">/</span>
<span class="n">ls</span>
</pre></div>
</div>
<p>您可以将 <code class="docutils literal notranslate"><span class="pre">resources</span></code> 目录下的所有文件拷贝至您的 Java 应用的 <code class="docutils literal notranslate"><span class="pre">resources</span></code> 目录下，weid-java-sdk 会自动加载相应的资源文件。</p>
<p>现在您可以使用 WeIdentity 开发您的区块链身份应用。weid-java-sdk 相关接口请见：<a class="reference external" href="https://weidentity.readthedocs.io/projects/javasdk/zh_CN/latest/docs/weidentity-java-sdk-doc.html">WeIdentity JAVA SDK文档</a> 。</p>
<p>我们提供了一个基于WeID的 <a class="reference external" href="https://github.com/WeBankBlockchain/weid-sample">开发样例</a>， 您可以参考。</p>
</div>
</div>
<div class="section" id="id8">
<h3>3. WeIdentity JAVA SDK 便捷工具使用<a class="headerlink" href="#id8" title="永久链接至标题">¶</a></h3>
<p>我们提供了一些快捷工具，可以帮您快速体验 weid-java-sdk，请参考<a class="reference external" href="./weidentity-quick-tools.html">WeIdentity JAVA SDK 便捷工具使用</a>。</p>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright (2018) WeBank Co., Ltd.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script src="../_static/translations.js"></script>
    

  

  <script type="text/javascript" src="../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>